﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JFTest.CommunicationService
{
    public delegate void ShowSocketData(string data);
    public abstract class NetworkDevice
    {
        #region 属性
        /// <summary>
        ///设备 IP地址
        /// </summary>
        private string _deviceIp;

        /// <summary>
        ///设备名称，例如 A01
        /// </summary>
        private string _equipmentName;

        private string _equipmentId;
        /// <summary>
        ///设备通讯端口号
        /// </summary>
        private int _devicePort;


        /// <summary>
        /// 是否连接OK
        /// </summary>
        private bool _isConnected;

        private bool _closeTag;//

        private bool _unabled;
        

        public string DeviceIp
        {
            get { return _deviceIp; }
            set { _deviceIp = value; }
        }
        public int DevicePort
        {
            get { return _devicePort; }
            set { _devicePort = value; }
        }
        public string EquipmentName
        {
            get { return _equipmentName; }
            set { _equipmentName = value; }
        }
        
        public bool IsConnected
        {
            get { return _isConnected; }
            set { _isConnected = value; }
        }

        public bool CloseTag { get => _closeTag; set => _closeTag = value; }
        public bool Unabled
        {
            get { return _unabled; }
            set { _unabled = value; }
        }

        public string EquipmentId { get => _equipmentId; set => _equipmentId = value; }
        #endregion
        public static ArrayList _socketList = new ArrayList();
        #region 方法
        

        /// <summary>
        /// 连接
        /// </summary>
        public abstract bool Connect();

        public abstract void ReConnect();
        /// <summary>
        /// 断开
        /// </summary>
        public abstract void Disconnect();
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public abstract string SendCommand(string command);
        /// <summary>
        /// 接收数据
        /// </summary>
        /// <returns></returns>
        public abstract string ReceiveData();

        /// <summary>
        /// 采集数据
        /// </summary>
        public abstract void DataCollection();

        #endregion
    }
}
